package org.springblade.modules.enterprise.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.modules.enterprise.entity.Content;
import org.springblade.modules.enterprise.entity.EsmsProductCloud;
import org.springblade.modules.enterprise.service.IContentService;
import org.springblade.modules.enterprise.vo.ContentVO;
import org.springblade.modules.enterprise.wrapper.ContentWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("/enterprise/policy-cloud")
@Api(value = "政策云接口", tags = "(api)政策云接口")
public class PolicyCloudApi {

	IContentService policyCloudService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入content")
	public R<ContentVO> detail(Content content) {
		Content detail = policyCloudService.getOne(Condition.getQueryWrapper(content));
		return R.data(ContentWrapper.build().entityVO(detail));
	}

	/**
	 * 详情
	 */
	@GetMapping("/detailForAPP")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入esmsCry")
	public R<Content> detailForAPP(Content content) {
		QueryWrapper<Content> esmscry=new QueryWrapper<>();
		esmscry.eq("id",content.getId());
		Content detail = policyCloudService.getOne(esmscry);
		return R.data(detail);
	}
	/**
	 * 分页 获取订阅的区域 产业 行业 所有文章
	 */
	@GetMapping("subscription")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "分页获取订阅文章", notes = "传入 标题、区域、产业、行业分类")
	public R<IPage<Content>> subscription(
		@RequestParam(value = "contentTitle", required = false) String contentTitle,
		@RequestParam(value = "contentArea", required = false) String area,
		@RequestParam(value = "contentProduct", required = false) String prod,
		@RequestParam(value = "contentIndustry", required = false) String industry,
		@RequestParam(value = "contentType", required = false) String contentType,
		Query query) {
		IPage<Content> page = policyCloudService.selectFlList(Condition.getPage(query),contentTitle,area, prod, industry, contentType);
		return R.data(page);
	}
}
